<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<x:parse xml="${param.xmlstr}" var="xmlData" />
<c:set var="title">经费预算表</c:set>
<c:if test="${not empty param.title }"><c:set var="title">${param.title }</c:set></c:if>

<table class="t_css" width="100%" border="0" cellpadding="0"
	id="invest_wide" cellspacing="1">
	<col width="5%"/>
	<col width="15%"/>
	<col width="40%"/>
	<col width="40%"/>
	<tr>
		<td colspan="2" align="center"><span class="color_red">*</span>预算投资总额（万元）：</td>
		<td colspan="2" align="left">
		<input name="proposal/invest_wide/budget_invest_total" id="budget_invest_total" type="text" label="预算投资总额" class=" input_text required valueEqual:budget_invest_total:budget_total maxlength:20" style="text-align:right;width:20%;" value="<x:out select="$xmlData/data/proposal/invest_wide/budget_invest_total" />"  
		   onfocus="InitInput.setNumber(this,7,4,2)" onchange="changeBlAuto(this.value);" />
		</td>
	</tr>
	<tr>
		<th align="center" class="TblHead" colspan="2" ><span class="color_red"></span>来    源</th>
		<th align="center" class="TblHead" ><span class="color_red">*</span>预算金额（万元）</th>
		<th align="center" class="TblHead" ><span class="color_red"></span>占预算总额的比例（%）</th>
	</tr>
	
	<tr>
		<td align="center" colspan="2" >依托单位投入</td>
		<td align="center">
		<input name="proposal/invest_wide/budget_dwtr" id="budget_dwtr" type="text" label="依托单位投入-->预算金额" class=" input_text required maxlength:20" style="text-align:right;width:80%" value="<x:out select="$xmlData/data/proposal/invest_wide/budget_dwtr" />"  
		     onfocus="InitInput.setNumber(this,7,4,2)" 
		     onchange="countNum1('budget_','dwtr,qy,kyys,gdyx,zgbmtr,tzjgtr,yhdk,other','total');countBl('budget_dwtr','zzbl_dwtr');getBlSum();"/>
		</td>
		<td align="center">
		<c:set var="zzbl_dwtr"><x:out select="$xmlData/data/proposal/invest_wide/zzbl_dwtr" /></c:set>
		<c:if test="${empty zzbl_dwtr }"><c:set var="zzbl_dwtr">0</c:set></c:if>
		<input name="proposal/invest_wide/zzbl_dwtr" id="zzbl_dwtr" type="text" label="依托单位投入-->占预算总额的比例" class=" input_text required maxlength:20 gray" style="text-align:right;width:80%" value="${zzbl_dwtr }"  
		     onfocus="InitInput.setNumber(this,7,4,2)" disabled="disabled"
		     onchange=""/>	
		</td>
	</tr>

	<tr>
		<td align="center" rowspan="3" >共<br/>建<br/>单<br/>位</td>
		<td align="center" >企 &nbsp; &nbsp;  &nbsp; &nbsp; 业</td>
		<td align="center">
		<input name="proposal/invest_wide/budget_qy" id="budget_qy" type="text" label="共建单位-->企业-->预算金额" class=" input_text required maxlength:20" style="text-align:right;width:80%" value="<x:out select="$xmlData/data/proposal/invest_wide/budget_qy" />"  
		     onfocus="InitInput.setNumber(this,7,4,2)" 
		     onchange="countNum1('budget_','dwtr,qy,kyys,gdyx,zgbmtr,tzjgtr,yhdk,other','total');countBl('budget_qy','zzbl_qy');getBlSum();"/>
		</td>
		<td align="center">
		<c:set var="zzbl_qy"><x:out select="$xmlData/data/proposal/invest_wide/zzbl_qy" /></c:set>
		<c:if test="${empty zzbl_qy }"><c:set var="zzbl_qy">0</c:set></c:if>
		<input name="proposal/invest_wide/zzbl_qy" id="zzbl_qy" type="text" label="共建单位-->企业-->占预算总额的比例" class=" input_text required maxlength:20 gray" style="text-align:right;width:80%" value="${zzbl_qy }"  
		     onfocus="InitInput.setNumber(this,7,4,2)" disabled="disabled"
		     onchange=""/>	
		</td>
	</tr>
	
	<tr>
		<td align="center" >科研院所</td>
		<td align="center">
		<input name="proposal/invest_wide/budget_kyys" id="budget_kyys" type="text" label="共建单位-->科研院所-->预算金额" class=" input_text required maxlength:20" style="text-align:right;width:80%" value="<x:out select="$xmlData/data/proposal/invest_wide/budget_kyys" />"  
		     onfocus="InitInput.setNumber(this,7,4,2)" 
		     onchange="countNum1('budget_','dwtr,qy,kyys,gdyx,zgbmtr,tzjgtr,yhdk,other','total');countBl('budget_kyys','zzbl_kyys');getBlSum();"/>
		</td>
		<td align="center">
		<c:set var="zzbl_kyys"><x:out select="$xmlData/data/proposal/invest_wide/zzbl_kyys" /></c:set>
		<c:if test="${empty zzbl_kyys }"><c:set var="zzbl_kyys">0</c:set></c:if>
	
		<input name="proposal/invest_wide/zzbl_kyys" id="zzbl_kyys" type="text" label="共建单位-->科研院所-->占预算总额的比例" class=" input_text required maxlength:20 gray" style="text-align:right;width:80%" value="${zzbl_kyys }"  
		     onfocus="InitInput.setNumber(this,7,4,2)" disabled="disabled"
		     onchange=""/>	
		</td>
	</tr>
	
	<tr>
		<td align="center" >高等院校</td>
		<td align="center">
		<input name="proposal/invest_wide/budget_gdyx" id="budget_gdyx" type="text" label="共建单位-->高等院校-->预算金额" class=" input_text required maxlength:20" style="text-align:right;width:80%" value="<x:out select="$xmlData/data/proposal/invest_wide/budget_gdyx" />"  
		     onfocus="InitInput.setNumber(this,7,4,2)" 
		     onchange="countNum1('budget_','dwtr,qy,kyys,gdyx,zgbmtr,tzjgtr,yhdk,other','total');countBl('budget_gdyx','zzbl_gdyx');getBlSum();"/>
		</td>
		<td align="center">
		<c:set var="zzbl_gdyx"><x:out select="$xmlData/data/proposal/invest_wide/zzbl_gdyx" /></c:set>
		<c:if test="${empty zzbl_gdyx }"><c:set var="zzbl_gdyx">0</c:set></c:if>
	
		<input name="proposal/invest_wide/zzbl_gdyx" id="zzbl_gdyx" type="text" label="共建单位-->高等院校-->占预算总额的比例" class=" input_text required maxlength:20 gray" style="text-align:right;width:80%" value="${zzbl_gdyx }"  
		     onfocus="InitInput.setNumber(this,7,4,2)" disabled="disabled"
		     onchange=""/>	
		</td>
	</tr>
	
	<tr>
		<td align="center" colspan="2" >依&nbsp; 托 &nbsp; 单 &nbsp;位<br/>主管部门投入</td>
		<td align="center">
		<input name="proposal/invest_wide/budget_zgbmtr" id="budget_zgbmtr" type="text" label="依托单位主管部门投入-->预算金额" class=" input_text required maxlength:20" style="text-align:right;width:80%" value="<x:out select="$xmlData/data/proposal/invest_wide/budget_zgbmtr" />"  
		     onfocus="InitInput.setNumber(this,7,4,2)" 
		     onchange="countNum1('budget_','dwtr,qy,kyys,gdyx,zgbmtr,tzjgtr,yhdk,other','total');countBl('budget_zgbmtr','zzbl_zgbmtr');getBlSum();"/>
		</td>
		<td align="center">
		<c:set var="zzbl_zgbmtr"><x:out select="$xmlData/data/proposal/invest_wide/zzbl_zgbmtr" /></c:set>
		<c:if test="${empty zzbl_zgbmtr }"><c:set var="zzbl_zgbmtr">0</c:set></c:if>
	
		<input name="proposal/invest_wide/zzbl_zgbmtr" id="zzbl_zgbmtr" type="text" label="依托单位主管部门投入-->占预算总额的比例" class=" input_text required maxlength:20 gray" style="text-align:right;width:80%" value="${zzbl_zgbmtr }"  
		     onfocus="InitInput.setNumber(this,7,4,2)" disabled="disabled"
		     onchange=""/>	
		</td>
	</tr>
	
	<tr>
		<td align="center" colspan="2" >投资机构投入</td>
		<td align="center">
		<input name="proposal/invest_wide/budget_tzjgtr" id="budget_tzjgtr" type="text" label="投资机构投入-->预算金额" class=" input_text required maxlength:20" style="text-align:right;width:80%" value="<x:out select="$xmlData/data/proposal/invest_wide/budget_tzjgtr" />"  
		     onfocus="InitInput.setNumber(this,7,4,2)" 
		     onchange="countNum1('budget_','dwtr,qy,kyys,gdyx,zgbmtr,tzjgtr,yhdk,other','total');countBl('budget_tzjgtr','zzbl_tzjgtr');getBlSum();"/>
		</td>
		<td align="center">
		<c:set var="zzbl_tzjgtr"><x:out select="$xmlData/data/proposal/invest_wide/zzbl_tzjgtr" /></c:set>
		<c:if test="${empty zzbl_tzjgtr }"><c:set var="zzbl_tzjgtr">0</c:set></c:if>
	
		<input name="proposal/invest_wide/zzbl_tzjgtr" id="zzbl_tzjgtr" type="text" label="投资机构投入-->占预算总额的比例" class=" input_text required maxlength:20 gray" style="text-align:right;width:80%" value="${zzbl_tzjgtr }"  
		     onfocus="InitInput.setNumber(this,7,4,2)" disabled="disabled"
		     onchange=""/>	
		</td>
	</tr>
	
	<tr>
		<td align="center" colspan="2" >银&nbsp; 行 &nbsp; 贷 &nbsp;款</td>
		<td align="center">
		<input name="proposal/invest_wide/budget_yhdk" id="budget_yhdk" type="text" label="银行贷款-->预算金额" class=" input_text required maxlength:20" style="text-align:right;width:80%" value="<x:out select="$xmlData/data/proposal/invest_wide/budget_yhdk" />"  
		     onfocus="InitInput.setNumber(this,7,4,2)" 
		     onchange="countNum1('budget_','dwtr,qy,kyys,gdyx,zgbmtr,tzjgtr,yhdk,other','total');countBl('budget_yhdk','zzbl_yhdk');getBlSum();"/>
		</td>
		<td align="center">
		<c:set var="zzbl_yhdk"><x:out select="$xmlData/data/proposal/invest_wide/zzbl_yhdk" /></c:set>
		<c:if test="${empty zzbl_yhdk }"><c:set var="zzbl_yhdk">0</c:set></c:if>
	
		<input name="proposal/invest_wide/zzbl_yhdk" id="zzbl_yhdk" type="text" label="银行贷款-->占预算总额的比例" class=" input_text required maxlength:20 gray" style="text-align:right;width:80%" value="${zzbl_yhdk }"  
		     onfocus="InitInput.setNumber(this,7,4,2)" disabled="disabled"
		     onchange=""/>	
		</td>
	</tr>
	
	<tr>
		<td align="center" colspan="2" >其 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &nbsp; &nbsp; 它</td>
		<td align="center">
		<input name="proposal/invest_wide/budget_other" id="budget_other" type="text" label="其它-->预算金额" class=" input_text required maxlength:20" style="text-align:right;width:80%" value="<x:out select="$xmlData/data/proposal/invest_wide/budget_other" />"  
		     onfocus="InitInput.setNumber(this,7,4,2)" 
		     onchange="countNum1('budget_','dwtr,qy,kyys,gdyx,zgbmtr,tzjgtr,yhdk,other','total');countBl('budget_other','zzbl_other');getBlSum();"/>
		</td>
		<td align="center">
		<c:set var="zzbl_other"><x:out select="$xmlData/data/proposal/invest_wide/zzbl_other" /></c:set>
		<c:if test="${empty zzbl_other }"><c:set var="zzbl_other">0</c:set></c:if>
	
		<input name="proposal/invest_wide/zzbl_other" id="zzbl_other" type="text" label="其它-->占预算总额的比例" class=" input_text required maxlength:20 gray" style="text-align:right;width:80%" value="${zzbl_other }"  
		     onfocus="InitInput.setNumber(this,7,4,2)" disabled="disabled"
		     onchange=""/>	
		</td>
	</tr>
	<tr>
	<td align="center" colspan="2">合 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &nbsp; &nbsp; 计</td>
	<td align="center">
	<c:set var="budget_total"><x:out select="$xmlData/data/proposal/invest_wide/budget_total" /></c:set>
		<c:if test="${empty budget_total }"><c:set var="budget_total">0</c:set></c:if>
	<input name="proposal/invest_wide/budget_total" id="budget_total" type="text" label="预算金额-->合计" class=" input_text required maxlength:20 gray" style="text-align:right;width:80%" value="${budget_total }"  
		     onfocus="InitInput.setNumber(this,7,4,2)" disabled="disabled"
		    />
	</td>
	<td align="center">
	<c:set var="zzbl_total"><x:out select="$xmlData/data/proposal/invest_wide/zzbl_total" /></c:set>
		<c:if test="${empty zzbl_total }"><c:set var="zzbl_total">0</c:set></c:if>
	
	<input name="proposal/invest_wide/zzbl_total" id="zzbl_total" type="text" label="占预算总额的比-->合计" class=" input_text required maxlength:20 gray" style="text-align:right;width:80%" value="${zzbl_total }"  
		      disabled="disabled"/>
	</td>	
	</tr>
</table>

<script type="text/javascript">
function countNum1(idStart, countStr, totalStr) {

	var indexs = countStr.split(",");
	var count = 0;
	for ( var i = 0; i < indexs.length; i++) {
		var fund = $("#" + idStart + indexs[i]).val();
		if (!$.isNumeric(fund))
			fund = "0";
		count = ((parseFloat(count)*10000 + parseFloat(fund)*10000)/10000).toFixed(4);
	}
	count = formatNumberAuto(count, 7, 4, 2);// 格式化金额
	$("#" + idStart + totalStr).val(count);
}

function countBl(idSource,idItem){
	var invest_total=$("#budget_invest_total").val();
	if(!$.isNumeric(invest_total)||invest_total==0){
		return;
	}
	invest_total=parseFloat(invest_total);
	var source=$("#"+idSource).val();
	if(!$.isNumeric(source)){
		return;
	}
	source=parseFloat(source);
	var val_item=(source/invest_total)*100;
	val_item=formatVal3(val_item.toString(),2);// 格式化金额,第二个参数表示四舍五入位数
	$("#" + idItem).val(val_item);
}

function changeBlAuto(totalBudget){
	if(!$.isNumeric(totalBudget)||totalBudget==0){
		return;
	}
	totalBudget=parseFloat(totalBudget);
	var temp=0;
	$("#invest_wide tr:gt(1)").each(function(i){
		temp=i+1;
		if(temp<9){
			if(temp==2){
				var td1=$(this).find("td:eq(2)").find("input").val();
				var res1=(td1/totalBudget)*100;
				$(this).find("td:eq(3)").find("input").val(formatVal3(res1.toString(),2));
				getBlSum();
			}else{
				var td1=$(this).find("td:eq(1)").find("input").val();
				var res1=(td1/totalBudget)*100;
				$(this).find("td:eq(2)").find("input").val(formatVal3(res1.toString(),2));
				getBlSum();
			}
		}
	});
	
}

//计算比例合计
function getBlSum(){
	$("#zzbl_total").val(formatVal3(($("#budget_total").val()/$("#budget_invest_total").val())*100),2);
}
</script>
	